<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form prependId="false" rendered="#{loginBacking.viewAllPurchaseOrder}">
                <p:panel header="#{bundle.ListPurchaseOrderEntityTitle} all Purchase Orders">
                    <p:messages />
                    <br />
                    <h:outputText escape="false" value="#{bundle.ListPurchaseOrderEntityEmpty}" rendered="#{purchaseOrderEntityController.items.rowCount == 0}"/>
                    <h:panelGroup rendered="#{purchaseOrderEntityController.items.rowCount > 0}">
                        <p:dataTable value="#{purchaseOrderEntityController.items}" 
                                     var="item" style="table-layout:fixed"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                            <p:column filterBy="#{item.id}">
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet>
                                <h:outputText value="#{item.id}"/>
                            </p:column>
                            <p:column filterBy="#{item.salesQuotation}">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle_salesQuotation}"/>
                                </f:facet>
                                <h:outputText value="#{item.salesQuotation}"/>
                            </p:column>
                            <p:column filterBy="#{item.salesOrder}">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle_salesOrder}"/>
                                </f:facet>
                                <h:outputText value="#{item.salesOrder}"/>
                            </p:column>
                            <p:column filterBy="#{item.customer.fullname}" filterMatchMode="contains">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle_customer}"/>
                                </f:facet>
                                <h:outputText value="#{item.customer.firstName}&nbsp;#{item.customer.lastName}"/>
                            </p:column>
                            <p:column filterBy="#{item.paymentMethod}">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle_paymentMethod}"/>
                                </f:facet>
                                <h:outputText value="#{item.paymentMethod}"/>
                            </p:column>
                            <p:column filterBy="#{item.createdBy.fullname}" filterMatchMode="contains">
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPurchaseOrderEntityTitle_createdBy}"/>
                                </f:facet>
                                <h:outputText value="#{item.createdBy.firstName}&nbsp;#{item.createdBy.lastName}"/>
                            </p:column>
                             <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" action="#{purchaseOrderEntityController.prepareView}" ajax="false"/>
                            </p:column>
                            <p:column>
                                <p:menuButton value="Options"> 
                                    <p:menuitem ajax="false" icon="ui-icon ui-icon-pencil" action="#{purchaseOrderEntityController.prepareEdit}" value="#{bundle.ListPurchaseOrderEntityEditLink}"/>
                                    <p:menuitem ajax="false" icon="ui-icon ui-icon-pencil" action="#{purchaseOrderEntityController.prepareReview}" value="Review" rendered="#{loginBacking.reviewPurchaseOrder}"/>
                                    <p:menuitem ajax="false" icon="ui-icon ui-icon-trash" action="#{purchaseOrderEntityController.destroy}" value="Delete" rendered="#{loginBacking.deletePurchaseOrder}"/>
                                </p:menuButton>
                            </p:column>
                        </p:dataTable>
                    </h:panelGroup>
                    <br />
                    <p:commandButton ajax="false" value="Search Purchase Order" action="/entities/purchaseOrderEntity/Search" immediate="true" />
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
